//
//  ILGUIViewController.m
//  ILGDemo
//
//  Created by zhangtongle-Pro on 2017/9/6.
//  Copyright © 2017年 Happy. All rights reserved.
//

#import "ILGUIViewController.h"
#import "ILGTestVC.h"

@interface ILGUIViewController ()
{
    
}
@property (weak, nonatomic) IBOutlet UIButton *actionBtnOne;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIView *testView;

@end

@implementation ILGUIViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self createUI];

    [self learnForOthers];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
//    NSLog(@"%s", __func__);
}

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    
//    NSLog(@"%s", __func__);
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
//    NSLog(@"%s", __func__);
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
//    NSLog(@"%s", __func__);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
//    NSLog(@"%s", __func__);
}


#pragma mark - UI

- (void)createUI
{
    /*
     UIButton: 圆角图片；背景颜色+cornerRadius,不用masksToBounds。
     UILabel: 背景颜色用backgroundColor，而不是layer.backgroundColor。
     UIImageView: 仅仅设置image和圆角，不会触发离屏渲染；如果同时设置backgroundColor则会触发
     */
    
//    self.actionBtnOne.titleLabel.backgroundColor = [UIColor whiteColor];
    self.actionBtnOne.layer.cornerRadius = 10;
    self.actionBtnOne.layer.masksToBounds = YES;
    self.actionBtnOne.tintColor = [UIColor blackColor];
    
    self.imageView.image = [UIImage imageNamed:@"girl-small.png"];
    self.imageView.backgroundColor = [UIColor blackColor];
    self.imageView.layer.cornerRadius = 10;
    
    self.label.textColor = [UIColor greenColor];
    self.label.layer.cornerRadius = 10;
    self.label.layer.masksToBounds = YES;
//    self.label.backgroundColor = [UIColor redColor]; //不触发离屏渲染
    self.label.layer.backgroundColor = [UIColor redColor].CGColor; //触发离屏渲染

    self.testView.backgroundColor = [UIColor redColor];
    self.testView.layer.cornerRadius = 20;
    self.testView.layer.masksToBounds = YES;
    
    self.testView.layer.rasterizationScale = YES;
}


#pragma mark - Event

- (IBAction)actionBtn1Clicked:(id)sender
{
    [self.navigationController pushViewController:p_viewController(@"ILGAnimationDisplayVC") animated:YES];
}

- (IBAction)actionBtn2Clicked:(id)sender
{
    UIViewController *vc = p_viewController(@"ILGTestVC");
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self showViewController:vc sender:self.tabBarController];
//    [self.tabBarController presentViewController:vc animated:YES completion:nil];
    
//    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)actionBtn3Clicked:(id)sender
{
    [self.navigationController pushViewController:p_viewController(@"ILGTestTableVC") animated:YES];
}


#pragma mark - other

- (void)learnForOthers
{
    NSLog(@"git rebase test 4");
    NSLog(@"git rebase test 5");
    NSLog(@"git rebase test 10");
    NSLog(@"git rebase release 1");
}

UIViewController * p_viewController(NSString *vcName)
{
    Class class = NSClassFromString(vcName);
    UIViewController *vc = [[class alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    return vc;
}

@end
